(n, c) = map(int, input().split(' '))
prices = list(map(int, input().split(' ')))
comparison = []
for i in range(n - 1):
if prices[i] > prices[i + 1]:
comparison.append(prices[i] - prices[i + 1])
if len(comparison) == 0:
print(0)
else:
if c > max(comparison):
print(0)
else:
print(max(comparison) - c)
//
// main.cpp
// A. Bear and Raspberry
//
// Created by Farrah Tharwat on 28/02/2023.
//
#include <iostream>
#include <map>
#include <vector>
//#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main() {
int n,r;
cin>>n>>r;
int a[n];
//vector<int> v;
int maxx=0;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n-1;i++){
//v.push_back(a[i]-a[i+1]);
maxx = max((a[i]-a[i+1]),maxx);
}
if((maxx-r)>=0)
cout<<maxx-r<<endl;
else
cout<<0<<endl;
//laptops
// int n,a,b;
// cin>>n;
// vector<pair<int , int>> v;
// while(n--){
// cin>>a>>b;
// v.push_back(make_pair(a, b));
// }
// sort(v.begin(), v.end());
// int x = v.begin()->second;
// vector<pair<int , int>>::iterator it;
// bool flag=0;
// for(it=v.begin();it!=v.end();++it){
// if(it->second < x)flag=1;
// x=it->second;
// }
// if(flag)
// cout<<"Happy Alex"<<endl;
// else
// cout<<"Poor Alex"<<endl;
}
1277A - Happy Birthday Polycarp | 577A - Multiplication Table |
817C - Really Big Numbers | 1355A - Sequence with Digits |
977B - Two-gram | 993A - Two Squares |
1659D - Reverse Sort Sum | 1659A - Red Versus Blue |
1659B - Bit Flipping | 1480B - The Great Hero |
1519B - The Cake Is a Lie | 1659C - Line Empire |
515A - Drazil and Date | 1084B - Kvass and the Fair Nut |
1101A - Minimum Integer | 985D - Sand Fortress |
1279A - New Year Garland | 1279B - Verse For Santa |
202A - LLPS | 978A - Remove Duplicates |
1304A - Two Rabbits | 225A - Dice Tower |
1660D - Maximum Product Strikes Back | 1513A - Array and Peaks |
1251B - Binary Palindromes | 768B - Code For 1 |
363B - Fence | 991B - Getting an A |
246A - Buggy Sorting | 884A - Book Reading |